#include "StdAfx.h"
#include "PhysicsObject.h"

PhysicsObject::PhysicsObject(void)
{
    m_fMass = 0.0f;
    m_vVelocity.ZeroOut();
    m_vPosition.ZeroOut();
    m_vAcceleration.ZeroOut();
}

PhysicsObject::~PhysicsObject(void)
{
}

/** Update this object */
void PhysicsObject::Update( float deltaTime )
{
    if ( m_fMass == 0.0f )
        return;

    Vector2f force(0, 0);
    size_t size = m_forces.size();
    for(size_t i = 0; i < size; ++i )
    {
        force = force + m_forces[i];
    }

    // Now add impulses
    while( !m_impulses.empty() )
    {
        force = force + m_impulses.back();
        m_impulses.pop_back();
    }

    // now calculate our new pos
    m_vAcceleration = force / m_fMass;
    m_vVelocity = /*m_vVelocity +*/ (m_vAcceleration * deltaTime);
    m_vPosition = m_vPosition + (m_vVelocity /** deltaTime*/);
}